package com.itheima.service.impl;

import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @program: Spring_day01_01_IOC入门程序
 * @description:
 * @author: xuejingjing
 * @create: 2021-07-30 14:19
 **/

//设置bean的作用域
@Scope("singleton")
//定义一个bean,后面添加bean的id
@Component("userService")
public class UserServiceImpl implements UserService {

    @Value("3")
    private int num;
    @Value("itheima")
    private String version;


    public void save(){
        System.out.println("user service running..."+"num="+num+","+"version="+version);
    }


    //设定bean的生命周期
    @PostConstruct
    public void init(){
        System.out.println("user service init...");
    }
    //设定bean的生命周期
    @PostConstruct
    public void destory(){
        System.out.println("user service desctory");
    }



}
